package com.kxc;

import com.kxc.domain.Person;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.jws.WebParam;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by kk on 2017/8/8.
 */
@Controller
@SpringBootApplication
public class DemoApplication {
    @RequestMapping("/index")
    public String index(Model model){
        Person single = new Person("all",18);
        List<Person> people = new ArrayList<Person>();
        Person p1=new Person("xx",11);
        Person p2 =new Person("yy",12);
        Person p3 =new Person("zz",13);
        people.add(p1);
        people.add(p2);
        people.add(p3);
        model.addAttribute("singlePerson",single);
        model.addAttribute("people",people);
        return "index";
    }
    @RequestMapping(value = "/search",produces = {MediaType.APPLICATION_JSON_VALUE})
    @ResponseBody
    public Person search(String personName){
        return new Person(personName,32);
    }
    public static void main(String[] args){
        SpringApplication.run(DemoApplication.class);
    }
}
